# Definition for a binary tree node.
# class TreeNode:
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None

class Solution:
    def mergeTrees(self, t1: TreeNode, t2: TreeNode) -> TreeNode:
        def merge(t1,t2):
            if t2.left is not None:
                if t1.left is None:
                    t1.left = TreeNode(t2.left.val)
                else:
                    t1.left.val+=t2.left.val
                merge(t1.left,t2.left)
            if t2.right is not None:
                if t1.right is None:
                    t1.right = TreeNode(t2.right.val)
                else:
                    t1.right.val+=t2.right.val
                merge(t1.right,t2.right)
        if t1 is None and t2 is not None:
            t1=TreeNode(t2.val)
        elif t1 is not None and t2 is not None:
            t1.val+=t2.val
        else:
            return t1
        merge(t1,t2)
        return t1